package com.foxzzz.two.pointers;


public class Solution925 {
    public boolean isLongPressedName(String name, String typed) {
        if (name.length() == 0 && typed.length() != 0) {
            return false;
        }
        int j = 0;
        for (int i = 0; i < name.length(); i++) {
            int len = 1;
            char c = name.charAt(i);
            while (i + 1 < name.length() && name.charAt(i + 1) == c) {
                len++;
                i++;
            }
            int len2 = 0;
            while (j  < typed.length() && typed.charAt(j ) == c) {
                len2++;
                j++;
            }
            if (len2 < len) {
                return false;
            }

        }
        return true;
    }


    public static void main(String[] args) {
        System.out.println(new Solution925().isLongPressedName("a", "a"));
        System.out.println(new Solution925().isLongPressedName("alex", "aaleex"));
        System.out.println(new Solution925().isLongPressedName("saeed", "ssaaedd"));
    }
}
